<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
var request=new XMLHttpRequest();

request.onreadystatechange=function()
{
    if (request.readyState==4 && request.status==200)
    {
        console.log(request.responseText);
        var div=document.getElementById("info");
        div.innerHTML=request.responseText;
    }else if(request.readyState==404){
    	
    	console.log("请求失败！");
    	var div=document.getElementById("info");
    	div.innerHTML="请求失败！";
    }
    
}
function say(){
	request.open("post","AjaxServlet",true);
	request.setRequestHeader( "Content-Type",
	 "application/x-www-form-urlencoded" );
	request.send("name=daxiong&thing="
			+document.
				getElementsByName("thing")[0].value);
	
}
</script>
</head>
<body>
hello
say something:<input type="text" name="thing">
<input type="button" onclick="say()" value="提交">
<div id="info"></div>
</body>

</html>